package Singleton;

//天生线程安全 加载类的时候就初始化完成了
public class HungrySingleton {
    public static void main(String[] args){
        testSingleton();
    }

    private HungrySingleton(){

    }

    public static void testSingleton(){
        HungrySingleton instance1 = HungrySingleton.getInstance();
        HungrySingleton instance2 = HungrySingleton.getInstance();
        System.out.print(instance1==instance2);
    }
    //
    private static HungrySingleton hungryInstance = new HungrySingleton();

    public static HungrySingleton getInstance(){
        return hungryInstance;
    }
}
